import userRouter from './user'
import publicRouter from './public'
import groupRouter from './group'
import attrRouter from './attr'
import type Koa from 'koa'
import { VerifyTokenRes } from '@/utils/token'

interface NewVerifyTokenRes extends VerifyTokenRes { userId: number }
export interface CustomRouterContext {
    global: {
        tokenInfo: NewVerifyTokenRes
    }
}

const useRouter = (app: Koa) => {
    userRouter.allowedMethods()
    app.use(userRouter.routes())
    publicRouter.allowedMethods()
    app.use(publicRouter.routes())
    groupRouter.allowedMethods()
    app.use(groupRouter.routes())
    attrRouter.allowedMethods()
    app.use(attrRouter.routes())
}

export default useRouter